/*
 * @Description: 车票订单创建提交页
 * @Author: shuaishuai.wang
 * @Date: 2019-08-21 09:42:50
 * @Last Modified by: shuaishuai.wang
 * @Last Modified time: 2019-08-23 16:17:12
 */
<template>
  <div
    class="create_main fontsize32"
    v-wechat-title="$route.meta.title"
  >
    <div class="create_area">
      <div class="ticket_info part">
        <div class="line_name flex-h flex-hsb">
          <h3 class="fontsize32">嘉虹1线</h3>
          <p class="fontsize28">19:30:59</p>
        </div>
        <div class="line_main">
          <div class="change_icon">
            <i class="iconfont icon-bus fontsize48"></i>
          </div>
          <div class="line_info">
            <div class="station">凯撒大帝</div>
            <div
              class="station_list"
              @click="toggleList = !toggleList"
            >
              <div
                class="station_num"
                :style="{height: (toggleList ? 0 : numHeight)}"
              >
                <span>4站</span>
                <i class="iconfont icon-unflod"></i>
              </div>
              <div
                class="station_way"
                :style="{height: (toggleList ? wayHeight : 0)}"
              >
                <p>苏丹皇宫</p>
                <p>蛋糕房</p>
                <p>国防航空</p>
                <p>普兰店</p>
              </div>
            </div>
            <div class="station">官方火凤凰</div>
            <div class="long_string">
              <i class="iconfont icon-circle start"></i>
              <i class="iconfont icon-circle end"></i>
            </div>
          </div>
        </div>
        <div class="ticket_time fontsize28">
          <span>班次：</span>2019年7月13日 08:30 - 7月20日 08:30
        </div>
        <div class="tag">
          <img :src="require('@static/img/day-ticket.png')">
        </div>
      </div>
      <div class="passenger part">
        <div class="num"><span>乘车人数：</span>1人</div>
        <div class="seat flex-h">
          <div class="title">座位号：</div>
          <div class="flex-h flex-hw">
            <p
              v-for="(seat, index) in seatList"
              :key="index"
              class="fontsize32"
            >{{seat}}</p>
          </div>
        </div>
      </div>
      <div class="price part">
        <div class="total_prices ">
          <span>票价：</span>￥20.00×1
        </div>
        <div class="discount">
          <span>折扣：</span>9折
        </div>
        <div class="sum_payable">实付：￥18.00</div>
      </div>
      <div class="explain">
        <i
          class="iconfont"
          :class="confirmExplain ? 'icon-circle-o' : 'icon-circle'"
          @click="confirmExplain = !confirmExplain"
        ></i>
        我已阅读并同意<span>“购票说明”</span></div>
      <div class="confirm">
        <button
          class="fontsize32"
          :class="confirmExplain ? '' : 'disabled_btn'"
          @click="buyTicket"
        >立即支付</button>
      </div>
    </div>

    <!--<div class="pay">
      <div class="pay_area">
        <div class="pay_title flex-h fontsize40">
          <i class="iconfont icon-cancel fontsize48"></i>
          <span>选择支付</span>
          <i></i>
        </div>
        <div class="payment_amount">￥18.00</div>
      </div>
    </div>-->
  </div>
</template>

<script>
export default {
  data () {
    return {
      toggleList: false, // 切换总站数与具体站名
      seatList: ['12座', '12座', '12排C座', '12座', '12座', '12座', '12排C座', '12座', '12座', '12排C座', '12座', '12排C座', '12座', '12座', '12座', '12座'], // 座位信息
      confirmExplain: false, // 是否勾选说明
      wayHeight: 0, // 存储具体站点所在div高度，用于动画效果
      numHeight: '' // 存储总站数所在div高度，用于动画效果
    }
  },
  mounted () {
    let size = parseFloat(document.getElementsByTagName('html')[0].style.fontSize) // 获取当前根字体大小
    this.numHeight = 0.746667 * size + 'px' // 计算站点数div高度
    this.wayHeight = 4 * 0.533333 * size + 'px' // 计算中间站点div高度
  },
  methods: {
    buyTicket () { // 确认支付前必须勾选说明，否则当前按钮无效果
      if (this.confirmExplain) {
        this.$router.push({ path: 'buyResult' })
      } else {
        this.showToast('请先确认')
      }
    }
  }
}
</script>

<style lang="scss" scoped>
html,
body {
  overflow: hidden;
}
.create_main {
  width: 100%;
  height: fill-available;
  position: relative;
  background-color: #f2f5f6;
  padding-top: 32px;
  box-sizing: border-box;
  font-weight: 400;
  overflow: auto;
  .create_area {
    height: 100%;
    position: relative;
  }
  .part {
    background-color: #fff;
    border-radius: 4px; /*no*/
    margin: 32px;
    margin-top: 0;
  }
  .ticket_info {
    position: relative;
    .line_name {
      height: 80px;
      line-height: 80px;
      h3 {
        padding-left: 108px;
      }
      p {
        padding-right: 32px;
        color: #027aff;
      }
    }
    .line_main {
      position: relative;
      .change_icon {
        width: fit-content;
        height: fit-content;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 32px;
        margin: auto;
        color: #027aff;
      }
      .line_info {
        padding-bottom: 28px;
        padding-left: 96px;
        .station {
          height: 44px;
          line-height: 44px;
          padding-left: 64px;
        }
        .station_list {
          padding: 10px 0;
          padding-left: 64px;
          .station_num {
            overflow: hidden;
            transition: all 0.5s;
            i {
              height: 56px;
              line-height: 56px;
              display: inline-block;
              color: #027aff;
            }
            span {
              height: 56px;
              line-height: 56px;
              display: inline-block;
            }
          }
          .station_way {
            overflow: hidden;
            transition: all 0.5s;
            p {
              height: 40px;
              line-height: 40px;
            }
          }
        }
        .long_string {
          width: 1px;
          border-left: 2px dashed #ccc;
          height: calc(100% - 48px);
          background-color: transparent;
          position: absolute;
          left: 112px;
          top: 10px;
          i {
            width: 32px;
            text-align: center;
            height: 36px;
            line-height: 36px;
            display: inline-block;
            color: #5c83ff;
            transform: scale(0.8);
            background-color: #fff;
            position: absolute;
            left: -17px;
          }
          .start {
            top: -10px;
          }
          .end {
            bottom: -10px;
          }
        }
      }
    }
    .ticket_time {
      height: 64px;
      line-height: 64px;
      margin: 0 32px;
      border-top: 1px solid #ddd; /*no*/
      span {
        color: #666;
      }
    }
    .tag {
      width: 100px;
      position: absolute;
      top: 0;
      left: 0;
      img {
        width: 100%;
      }
    }
  }
  .passenger {
    padding: 32px;
    .num {
      margin-bottom: 32px;
      span {
        color: #666;
      }
    }
    .seat {
      .title {
        white-space: nowrap;
        color: #666;
      }
      p {
        background-color: #027aff;
        color: #fff;
        border-radius: 4px; /*no*/
        margin-left: 32px;
        margin-bottom: 16px;
        padding: 0 8px;
      }
    }
  }
  .price {
    padding: 32px;
    span {
      color: #666;
    }
    .total_prices {
      padding-bottom: 32px;
    }
    .discount {
      padding-bottom: 52px;
    }
    .sum_payable {
      color: #e84d38;
      padding-top: 14px;
      border-top: 1px solid #ddd; /*no*/
    }
  }
  .explain {
    padding: 0 32px;
    height: 48px;
    line-height: 48px;
    i {
      width: 48px;
      height: 48px;
      line-height: 48px;
      text-align: center;
      display: inline-block;
    }
    span {
      color: #027aff;
    }
    .icon-circle-o {
      color: #027aff;
    }
  }
  .confirm {
    margin: 0 32px;
    margin-top: 200px;
    button {
      width: 686px;
      height: 72px;
      border: 0;
      background-color: #027aff;
      color: #fff;
      border-radius: 25px; /*no*/
      position: absolute;
      bottom: 32px;
      transition: all 0.5s;
    }
    .disabled_btn {
      background-color: #ccc;
    }
  }
  .pay {
    width: 100%;
    height: 100%;
    position: fixed;
    z-index: 99;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.5);
    .pay_area {
      width: 100%;
      background-color: #fff;
      position: absolute;
      bottom: 0;
      border-radius: 10px 10px 0px 0px; /*no*/
      .pay_title {
        text-align: center;
        height: 112px;
        line-height: 112px;
        border-bottom: 1px solid #eee; /*no*/
        i {
          width: 112px;
          height: 112px;
          display: inline-block;
          color: #ccc;
        }
        span {
          width: 526px;
          display: inline-block;
        }
      }
      .payment_amount {
        height: 116px;
        line-height: 116px;
        text-align: center;
        font-weight: 500;
      }
    }
  }
}
</style>
